import { defineStore } from 'pinia'
import { getHotSuggest, getCategory, getHouseData } from "@/services/modules/home"
const useHomeStore = defineStore('home', {
  state: () => ({
    hotSuggestList: [],
    categories: [],
    houseList: [],
    currentPage: 1
  }),
  actions: {
    async getHotSuggestList() {
      const { data } = await getHotSuggest()
      this.hotSuggestList = data
    },
    async getCategories() {
      const { data } = await getCategory()
      this.categories = data
    },
    async getHouseList() {
      const res = await getHouseData(this.currentPage)
      console.log(res.data, 'houseList');
      this.houseList.push(...res.data)
      this.currentPage++
    }

  }
})
export default useHomeStore